<?php
/*
 * This file houses all misc. functions for lightbox
 *
 */

define("IMAGE_FILETYPE", "(bmp|gif|jpeg|jpg|png)", true);

function wp_lightbox2_replace($string) {
	$pattern = '/(<a(.*?)href="([^"]*.)'.IMAGE_FILETYPE.'"(.*?)><img)/ie';
  	$replacement = 'stripslashes(strstr("\2\5","rel=") ? "\1" : "<a\2href=\"\3\4\"\5 rel=\"lightbox\"><img")';
	return preg_replace($pattern, $replacement, $string);
}

?>